<template>
  <div class="set_token">
  </div>
</template>
<script>
import { Dialog } from 'vant';

export default {
  data() {
    return {}
  },
  methods: {
    save(){
      /* 
        alert 
        title: '支付确认',
        message: '请确定微信支付是否已完成？',
        confirmButtonText:'点击返回车煮APP'
      */
      Dialog.confirm({
        title: '支付确认',
        message: '如已完成支付，请点击“已付款”\n如支付遇到问题，请点击“取消”并重新支付',
        confirmButtonText:'已付款',
        cancelButtonColor:'red'
      }).then(() => {
        let u = navigator.userAgent;
        let isAndroid = u.indexOf("Android") > -1 || u.indexOf("Adr") > -1; //android终端
        let isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
        // android();
        if (isAndroid) {
          window.location.href ='cncomdo1cookcarc://index';   // 打开app的协议，有安卓同事提供
          window.setTimeout(() => {
            window.location.href = 'cncomdo1cookcarc://index';   // 打开app的协议，有安卓同事提供
            // window.location.href = 'http://www.wjtr.com/download/index.html';  //下载app的协议，有安卓同事提供
          }, 2000);
        }
        if (isIOS) {
          let ifr = document.createElement("iframe");
          ifr.src ='cncomdo1cookcarc://index';  // 打开app的协议，有ios同事提供
          ifr.style.display = "none";
          document.body.appendChild(ifr);
          window.setTimeout(() => {
            document.body.removeChild(ifr);
            window.location.href ='cncomdo1cookcarc://index';   // 打开app的协议，有安卓同事提供
            // window.location.href ='http://www.wjtr.com/download/index.html';  // 下载app的地址
          }, 2000);
        }
        /* sessionStorage.setItem('token', this.tokenValue);
        this.$router.push({
          name:'Index'
        }) */
      }).catch(() => {
        let u = navigator.userAgent;
        let isAndroid = u.indexOf("Android") > -1 || u.indexOf("Adr") > -1; //android终端
        let isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
        // android();
        if (isAndroid) {
          window.location.href ='cncomdo1cookcarc://index';   // 打开app的协议，有安卓同事提供
          window.setTimeout(() => {
            window.location.href = 'cncomdo1cookcarc://index';   // 打开app的协议，有安卓同事提供
            // window.location.href = 'http://www.wjtr.com/download/index.html';  //下载app的协议，有安卓同事提供
          }, 2000);
        }
        if (isIOS) {
          let ifr = document.createElement("iframe");
          ifr.src ='cncomdo1cookcarc://index';  // 打开app的协议，有ios同事提供
          ifr.style.display = "none";
          document.body.appendChild(ifr);
          window.setTimeout(() => {
            document.body.removeChild(ifr);
            window.location.href ='cncomdo1cookcarc://index';   // 打开app的协议，有安卓同事提供
            // window.location.href ='http://www.wjtr.com/download/index.html';  // 下载app的地址
          }, 2000);
        }
      });
    }
  },
  created(){
    this.save()
  }
}
</script>
<style lang="less" scoped>
.set_token{
  .token_btn{
    width: 100vw;
    display: flex;
    justify-content: center;
    margin-top: 20px;
  }
}
</style>